package com.example.demo;


import com.example.demo.enity.Authority;
import com.example.demo.enity.User;
import com.example.demo.mapper.AuthorityMapper;
import com.example.demo.mapper.UserMapper;
import com.example.demo.service.AuthorityService;
import com.example.demo.service.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

//作用:告诉java你这个类通过用什么运行环境运行
@RunWith(SpringRunner.class)
//如果测试的东西需要以SpringBoot为基础（例如需要使用spring boot内部的东西（@Autowired））添加该注解
//是一个类的注解
@SpringBootTest
public class TestClass {

//    @Autowired
//    RedisTemplate redisTemplate;

    @Autowired
    AuthorityService authorityService;

    @Test
    public void test() {
        List<Authority> object = authorityService.getAuthorityByUsername("jiaYao");
        System.out.println(object);
    }

//    @Test
//    public void testRedis() {


//        List<Bill> bills = new ArrayList<>();
//        for (int i = 0; i <5 ; i++) {
//            Bill bill = new Bill();
//            bill.setBillId(i);
//            bills.add(bill);
//        }
//        redisTemplate.opsForValue().set("bills",bills);

//        List<Bill> bills = (List<Bill>)redisTemplate.opsForValue().get("bills");
//        System.out.println(bills);

//        redisTemplate.opsForValue().set("bill",new Bill());
//
//        Bill bill = (Bill)redisTemplate.opsForValue().get("bill");
//        System.out.println(bill);

//        Object bill1 = redisTemplate.opsForValue().get("bill");
//        ObjectMapper objectMapper = new ObjectMapper();
//        Bill bill = objectMapper.convertValue(bill1, Bill.class);
//        System.out.println(bill);


//
//        Object bill = redisTemplate.opsForValue().get("bill");
//        System.out.println(bill);


//        redisTemplate.opsForValue().set("bill",new Bill());

//        Bill bill = (Bill)redisTemplate.opsForValue().get("bill");
//        System.out.println(bill);


//    }
}
